API Documentation
Matrix.h
1 // Matrix.h
3 //
5 
6 namespace nkMaths
7 {
13  class Matrix : public ByteAlignedClass<16>
14  {
15  public :
16 
17  // Attributes
18  std::array<std::array<float, 4>, 4> _m ;
19 
20  public :
21 
26  Matrix () ;
38  Matrix (float m00, float m01, float m10, float m11) ;
55  Matrix (float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22) ;
78  Matrix (float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33) ;
84  Matrix (const Matrix& other) ;
88  ~Matrix () ;
89 
90  // Getters
94  Vector getRow0 () const ;
98  Vector getRow1 () const ;
102  Vector getRow2 () const ;
106  Vector getRow3 () const ;
110  Vector getCol0 () const ;
114  Vector getCol1 () const ;
118  Vector getCol2 () const ;
122  Vector getCol3 () const ;
131  float get (unsigned int row, unsigned int col) const ;
132 
133  // Setters
143  Matrix& set (float val, unsigned int row, unsigned int col) ;
144 
145  // Alterations
161  Matrix getTranspose () const ;
186 
187  // Transformations
213  void getDecomposed (Vector& position, Quaternion& orientation, Vector& scale) ;
214 
223  Matrix& setToViewMatrixDirection (const Vector& position, const Vector& direction, const Vector& upDirection) ;
236  Matrix& setToPerspectiveMatrix (float fov, float aspect, float nearVal, float farVal) ;
249  Matrix& setToOrthographicMatrix (float widthNearPlane, float heightNearPlane, float nearVal, float farVal) ;
256  Matrix& setPositionComponent (const Vector& position) ;
270  Matrix& setScaleComponent (const Vector& scale) ;
279  Matrix& setToTransformation (const Vector& position, const Quaternion& orientation, const Vector& scale) ;
280 
288  Vector transform (const Vector& vector) const ;
289 
290  // Utilities
294  float getDeterminantMat2 () const ;
298  float getDeterminantMat3 () const ;
302  float getDeterminantMat4 () const ;
306  float getTraceMat3 () const ;
310  float getTraceMat3 () const ;
314  float getTraceMat4 () const ;
315 
325 
326  // Operators
333  Matrix& operator= (const Matrix& other) ;
340  bool operator== (const Matrix& other) ;
347  bool operator!= (const Matrix& other) ;
354  Matrix operator+ (const Matrix& other) const ;
360  void operator+= (const Matrix& other) ;
367  Matrix operator- (const Matrix& other) const ;
373  void operator-= (const Matrix& other) ;
380  Matrix operator* (const Matrix& other) const ;
387  Vector operator* (const Vector& toApply) const ;
396  Quaternion operator* (const Quaternion& toApply) const ;
403  Matrix operator* (float scalar) const ;
409  void operator*= (const Matrix& other) ;
415  void operator*= (float scalar) ;
422  Matrix operator/ (float scalar) const ;
428  void operator /= (float scalar) ;
429  } ;
430 }
nkMaths::Matrix::getTraceMat4
float getTraceMat4() const
nkMaths::Matrix::~Matrix
~Matrix()
nkMaths::Matrix::setToPerspectiveMatrix
Matrix & setToPerspectiveMatrix(float fov, float aspect, float nearVal, float farVal)
nkMaths::Matrix::operator!=
bool operator!=(const Matrix &other)
nkMaths::Matrix::getInverseMat3
Matrix getInverseMat3() const
nkMaths::Matrix::getDecomposed
void getDecomposed(Vector &position, Quaternion &orientation, Vector &scale)
nkMaths::Matrix::inverseMat4
Matrix & inverseMat4()
nkMaths::Matrix::getInverseMat4
Matrix getInverseMat4() const
nkMaths::Matrix::setOrientationComponent
Matrix & setOrientationComponent(const Quaternion &rot)
nkMaths::Matrix::operator*
Matrix operator*(const Matrix &other) const
nkMaths
Encompasses all API of component NilkinsMaths.
Definition: IntVector.h:7
nkMaths::Matrix::transpose
Matrix & transpose()
nkMaths::Quaternion
A quaternion, symbolizing rotations as a 4D vector.
Definition: Quaternion.h:14
nkMaths::Matrix::getCol1
Vector getCol1() const
nkMaths::Matrix::setScaleComponent
Matrix & setScaleComponent(const Vector &scale)
nkMaths::Matrix::getCol0
Vector getCol0() const
nkMaths::Matrix::getTraceMat3
float getTraceMat3() const
nkMaths::Matrix::getRow3
Vector getRow3() const
nkMaths::Matrix::getRow2
Vector getRow2() const
nkMaths::Matrix
Represents a 4x4 float matrix.
Definition: Matrix.h:14
nkMaths::Matrix::operator-=
void operator-=(const Matrix &other)
nkMaths::Matrix::getScaleComponent
Vector getScaleComponent() const
nkMaths::Matrix::Matrix
Matrix()
nkMaths::Matrix::getCol3
Vector getCol3() const
nkMaths::Matrix::inverseMat3
Matrix & inverseMat3()
nkMaths::Matrix::operator==
bool operator==(const Matrix &other)
nkMaths::Matrix::getCol2
Vector getCol2() const
nkMaths::Matrix::operator/=
void operator/=(float scalar)
nkMaths::Matrix::setToViewMatrixDirection
Matrix & setToViewMatrixDirection(const Vector &position, const Vector &direction, const Vector &upDirection)
nkMaths::Matrix::getDeterminantMat3
float getDeterminantMat3() const
nkMaths::Matrix::Matrix
Matrix(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
nkMaths::Matrix::Matrix
Matrix(float m00, float m01, float m10, float m11)
nkMaths::Matrix::setPositionComponent
Matrix & setPositionComponent(const Vector &position)
nkMaths::Matrix::getDeterminantMat4
float getDeterminantMat4() const
nkMaths::Matrix::setToOrthographicMatrix
Matrix & setToOrthographicMatrix(float widthNearPlane, float heightNearPlane, float nearVal, float farVal)
nkMaths::Matrix::getDeterminantMat2
float getDeterminantMat2() const
nkMaths::Matrix::transform
Vector transform(const Vector &vector) const
nkMaths::Matrix::operator+
Matrix operator+(const Matrix &other) const
nkMaths::Matrix::operator-
Matrix operator-(const Matrix &other) const
nkMemory::StringView
Class holding information about a string, with no ownership over the data.
Definition: StringView.h:22
nkMaths::Matrix::setToTransformation
Matrix & setToTransformation(const Vector &position, const Quaternion &orientation, const Vector &scale)
nkMaths::Matrix::getRow0
Vector getRow0() const
nkMaths::Matrix::inverseMat2
Matrix & inverseMat2()
nkMaths::Matrix::_m
std::array< std::array< float, 4 >, 4 > _m
The matrix memory, considered in row-major order (_m[row][col]).
Definition: Matrix.h:18
nkMaths::Matrix::Matrix
Matrix(float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33)
nkMaths::Matrix::getOrientationComponent
Matrix getOrientationComponent() const
nkMaths::Matrix::operator=
Matrix & operator=(const Matrix &other)
nkMaths::Matrix::Matrix
Matrix(const Matrix &other)
nkMaths::Matrix::getRow1
Vector getRow1() const
nkMaths::Matrix::fromString
Matrix & fromString(const nkMemory::StringView &str)
nkMaths::Matrix::getPositionComponent
Vector getPositionComponent() const
nkMaths::Matrix::operator*=
void operator*=(const Matrix &other)
nkMaths::Vector
A 4-component vector class, with floats.
Definition: Vector.h:12
nkMaths::Matrix::get
float get(unsigned int row, unsigned int col) const
nkMaths::Matrix::getTranspose
Matrix getTranspose() const
nkMaths::Matrix::set
Matrix & set(float val, unsigned int row, unsigned int col)
nkMaths::Matrix::operator/
Matrix operator/(float scalar) const
nkMaths::Matrix::getInverseMat2
Matrix getInverseMat2() const
nkMaths::Matrix::operator+=
void operator+=(const Matrix &other)